Attribute VB_Name = "modFunctions"
Option Explicit

'Registry Function Prototypes
Declare Function RegOpenKeyEx Lib "advapi32" _
  Alias "RegOpenKeyExA" ( _
  ByVal hKey As Long, _
  ByVal lpSubKey As String, _
  ByVal ulOptions As Long, _
  ByVal samDesired As Long, _
  phkResult As Long _
) As Long

Declare Function RegQueryValueEx Lib "advapi32" _
  Alias "RegQueryValueExA" ( _
  ByVal hKey As Long, _
  ByVal lpValueName As String, _
  ByVal lpReserved As Long, _
  ByRef lpType As Long, _
  ByVal szData As String, _
  ByRef lpcbData As Long _
) As Long

Declare Function RegCloseKey Lib "advapi32" ( _
  ByVal hKey As Long _
) As Long

Type TSECURITY_ATTRIBUTES
  nLength As Long
  lpSecurityDescriptor As Long
  bInheritHandle As Boolean
End Type

Declare Function RegCreateKeyEx Lib "advapi32" _
  Alias "RegCreateKeyExA" ( _
  ByVal hKey As Long, _
  ByVal lpSubKey As String, _
  ByVal Reserved As Long, _
  ByVal lpClass As String, _
  ByVal dwOptions As Long, _
  ByVal samDesired As Long, _
  lpSecurityAttributes As TSECURITY_ATTRIBUTES, _
  phkResult As Long, _
  lpdwDisposition As Long _
) As Long

Declare Function RegSetValueEx Lib "advapi32" _
  Alias "RegSetValueExA" ( _
  ByVal hKey As Long, _
  ByVal lpValueName As String, _
  ByVal Reserved As Long, _
  ByVal dwType As Long, _
  ByVal szData As String, _
  ByVal cbData As Long _
) As Long

'********************************************************************************************************
'##ModelId=3521FD15008C
Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

'##ModelId=3521FD1602DA
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

Public Function ReplaceTESTRefs(ByVal XMLString As String) As String
    Dim sReturnValue As String
    Dim RegSettings As clsReg
    Dim DTDLocation As String
    
    Set RegSettings = New clsReg
    sReturnValue = XMLString
       
    If RegSettings.DebugMode = "Y" Then
        'sReturnValue = Replace(sReturnValue, "LCB01", "LCB")
        'sReturnValue = Replace(sReturnValue, "LCB02", "LCB")
        'sReturnValue = Replace(sReturnValue, "LCB03", "LCB")
        
        DTDLocation = RegSettings.DTDLocation
        
        If Len(DTDLocation) > 0 Then
            'if the string hasn't been fixed already, fix it
            If Not InStr(sReturnValue, DTDLocation) > 0 Then
                sReturnValue = Replace(sReturnValue, "CancelRequest.dtd", DTDLocation & "CancelRequest.dtd")
                sReturnValue = Replace(sReturnValue, "FormB_Request.dtd", DTDLocation & "FormB_Request.dtd")
                sReturnValue = Replace(sReturnValue, "FormAD_Request.dtd", DTDLocation & "FormAD_Request.dtd")
            End If
        End If
    End If
    
    Set RegSettings = Nothing
    ReplaceTESTRefs = sReturnValue
End Function


